home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / Menu / c / FullDispos < prev    next >
Text File  |  1995-07-08  |  1KB  |  49 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Menu.FullDispos.c
  12.     Author:  Copyright © 1994 Tony Houghton
  13.     Version: 1.01 (15 Nov 1994)
  14.     Purpose: Dispose of a menu and its indirected data.
  15. */
  16.  
  17. #include <stdlib.h>
  18.  
  19. #include "DeskLib:Menu.h"
  20.  
  21. #define ENTRY(menu) ((menu_item *) ((int) (menu) + sizeof(menu_block)))
  22.  
  23.  
  24. void Menu_FullDispose(menu_ptr menu)
  25. {
  26.   int index;
  27.   menu_item *items = ENTRY(menu);
  28.  
  29.   /* Free title data if necessary */
  30.   if (items[0].menuflags.data.indtitle)
  31.     free (((icon_data *) menu->title)->indirecttext.buffer);
  32.     /* Menu_New makes title validation -1 */
  33.  
  34.   /* Process entries */
  35.   for (index = 0;;index++)
  36.   {
  37.     if (items[index].iconflags.data.indirected)
  38.     {
  39.       free(items[index].icondata.indirecttext.buffer);
  40.  
  41.       if ((int) items[index].icondata.indirecttext.validstring > 0)
  42.         free(items[index].icondata.indirecttext.validstring);
  43.     }
  44.  
  45.     if (items[index].menuflags.data.last)
  46.       break;
  47.   }
  48. }
  49.